﻿
using System;
using System.Web;

public class PicHandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        string filename = context.Server.MapPath(context.Request.FilePath);
        try
        {
            if (context.Request == null)
            {
                context.Response.ContentType = "image/GIF";
                context.Response.WriteFile("err.gif");
            }
            else
            {
                if (context.Request.UrlReferrer.Host.Contains("localhost:1037"))
                {
                    context.Response.ContentType = "image/JPEG";
                    context.Response.WriteFile(filename);

                }
                else
                {
                    context.Response.ContentType = "image/GIF";
                    context.Response.WriteFile("err.gif");
                }
            }
        }
        catch
        { }
       
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}